package com.team233.zuccecho.rabbitMQ;

import com.team233.zuccecho.dto.FeedbackDao;
import com.team233.zuccecho.result.ExceptionMsg;
import com.team233.zuccecho.result.ResponseData;
import com.team233.zuccecho.service.inter.StudentInterface;
import com.team233.zuccecho.util.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

/**
 * @author pengbin
 * @version 1.0
 * 工作队列模式
 */
@RabbitListener(queues = {Constants.QUE_WORK_QUEUE})
public class WorkQueueConsumer {
    @Autowired
    private StudentInterface studentInterface;
    private String name;
    public WorkQueueConsumer(String name) {
        this.name = name;
    }
    @RabbitHandler
    public void handleMsg(ZuccEchoMessage msg) throws IOException {
        Long fd_id=studentInterface.submitQuestionnaire((FeedbackDao) msg.getContent().get("feedback"));
        System.out.println(this.name+"add FeedbackId: "+fd_id);
    }
}
